cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
        _head:null,
        _name:null,
        _gems:null,
    },

    // use this for initialization
    onLoad: function () {
        this._head = cc.find("Canvas/userinfo/head/icon").getComponent(cc.Sprite);
        this._name = cc.find("Canvas/userinfo/name").getComponent(cc.Label);
        this._gems = cc.find("Canvas/userinfo/gems").getComponent(cc.Label);
        
        var userinfo = cc.find("Canvas/userinfo");
        this.node.on("switch_page",function(data){
           var pageName = data.detail;
           userinfo.active = pageName != "login";
        }.bind(this));
    },
    
    setGems:function(gems){
        this._gems.string = "房卡:" + gems;
    },
    
    setUserInfo:function(headimg,name,gems){
        this._name.string = name;
        this._gems.string = "房卡:" + gems;
        return;
        var url = headimg + ".jpg";
        cc.loader.load(url,function (err,tex) {
            if(tex){
                var spriteFrame = new cc.SpriteFrame(tex, cc.Rect(0, 0, tex.width, tex.height));
                this._head.spriteFrame = spriteFrame;                
            }
            else{
                console.log(err);
            }

        }.bind(this));
    }

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
